package com.lancoo.ccas53.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.lancoo.ccas53.entity.*;
import com.lancoo.ccas53.pojo.dto.*;
import com.lancoo.ccas53.pojo.response.basicPlatform.BaseCourse;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * <p>
 * 选课课程 服务类
 * </p>
 *
 * @author quin.song
 * @since 2024-05-20
 */
public interface CssSelectCourseService extends IService<CssSelectCourse> {

    /**
     * 获取选课要求
     *
     * @param type
     * @param taskId
     * @return
     */
    CssTaskInfo getCssTask(Integer type, Integer taskId);

    /**
     * 设置选课要求
     *
     * @param param
     * @param taskId
     * @return
     */
    CssTaskInfo setCssTask(CssTaskInfo param, Integer taskId);

    /**
     * 获取已选选课课程列表
     *
     * @param type
     * @param baseCollegeId
     * @param courseTypeId
     * @param courseNature
     * @param keyword
     * @param sexLimit
     * @param taskId
     * @return
     */
    List<SelectCourseListDto> getSelectCourseList(Integer type, Integer dataRange, String baseCollegeId, String courseTypeId, Integer courseNature, String keyword, Integer sexLimit, Integer flag, Integer taskId);

    /**
     * 批量设置选课课程
     *
     * @param list
     * @param taskId
     * @return
     */
    List<CssSelectCourse> addSelectCourse(List<CssSelectCourse> list, Integer type, Integer taskId);

    /**
     * 批量设置课程限制
     *
     * @param idList
     * @param sexLimit
     * @param classNum
     * @param operationStatus
     * @param isEnable
     * @param description
     * @param taskId
     * @return
     */
    String setCourseLimit(List<Integer> idList, Optional<Integer> sexLimit, Optional<Integer> classNum, Optional<Integer> operationStatus, Optional<Integer> isEnable, Optional<String> description, Integer taskId);

    /**
     * 获取选课轮次列表
     *
     * @param type
     * @param taskId
     * @return
     */
    List<RoundListDto> getRoundList(Optional<Integer> type, Integer taskId);

    /**
     * 添加更新选课轮次信息
     *
     * @param param
     * @param taskId
     * @return
     */
    Boolean addOrUpdateRound(RoundListDto param, String authorization, Integer taskId) throws UnsupportedEncodingException;

    /**
     * 删除自选轮次课程
     *
     * @param roundId
     * @param courseId
     * @param taskId
     * @return
     */
    Boolean deleteRoundCourseToSelf(Integer roundId, List<Integer> courseId, Integer taskId);

    /**
     * 删除选课轮次
     *
     * @param id
     * @param taskId
     * @return
     */
    Boolean removeRound(Integer id, Integer taskId);

    /**
     * 查看预选课选课日志
     *
     * @param baseCollegeId
     * @param gradeId
     * @param classId
     * @param courseId
     * @param startDateTime
     * @param endDateTime
     * @param keyword
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<PreLogsDto> getPreLogs(Long roundId, String baseCollegeId, String gradeId, String classId, Long courseId, String startDateTime, String endDateTime, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 确定预选课结果列表
     *
     * @param baseCollegeId
     * @param courseTypeId
     * @param courseNature
     * @param keyword
     * @param isEnable
     * @param isAchieveOpen
     * @param taskId
     * @return
     */
    ResultDto<PreResultDto> getPreResultList(String baseCollegeId, String courseTypeId, Optional<Integer> courseNature, String keyword, Optional<Integer> isEnable, Optional<Integer> isAchieveOpen, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 统计选课
     *
     * @param type
     * @param taskId
     * @return
     */
    Map<String, Object> publishStatistics(Integer type, Integer taskId);

    /**
     * 获取选课学生列表
     *
     * @param baseCollegeId
     * @param gradeId
     * @param classId
     * @param isSelect
     * @param keyword
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<StudentDto> getStudentList(String baseCollegeId, String gradeId, Optional<Integer> classId, Optional<Integer> isSelect, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 获取选课教学班列表
     *
     * @param baseCollegeId
     * @param courseTypeId
     * @param courseNature
     * @param courseId
     * @param keyword
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<TeachingClassDto> getTeachingClassList(String baseCollegeId, String courseTypeId, Integer courseNature, Integer courseId, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 获取选课学生范围
     *
     * @param flag
     * @param taskId
     * @return
     */
    List<StudentRangeDto> getStudentRangeList(Integer flag, Integer taskId);

    /**
     * 获取选课课程范围
     *
     * @param baseCollegeId
     * @param courseTypeId
     * @param courseNature
     * @param keyword
     * @param taskId
     * @return
     */
    List<CourseRangeDto> getClassRangeList(String baseCollegeId, String courseTypeId, String courseNature, String keyword, List<CssStudentRange> rangeList, Integer taskId);

    /**
     * 取消预选课开课状态
     *
     * @param idList
     * @param isEnable
     * @param reason
     * @param remindWay
     * @param taskId
     * @return
     */
    Boolean setCourseStatus(List<Integer> idList, Integer isEnable, String reason, Integer remindWay, Integer taskId);

    /**
     * 确认发布
     *
     * @param baseCollegeIdList
     * @param userId
     * @param userName
     * @param taskId
     * @return
     */
    Boolean confirmPreResult(List<String> baseCollegeIdList, String userId, String userName, Integer type, Integer taskId);

    /**
     * 按专业查询预选课程
     *
     * @param baseCollegeId
     * @param gradeId
     * @param baseMajorId
     * @param keyword
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<MajorGrade> getCourseByMajor(String baseCollegeId, String gradeId, String baseMajorId, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 复制选课轮次
     *
     * @param id
     * @param taskId
     * @return
     */
    Boolean copyRound(Integer id, Integer taskId);

    /**
     * 批量设置选课上限（按专业）
     *
     * @param idList
     * @param preCreditLimit
     * @param preCourseLimit
     * @param creditLimit
     * @param courseLimit
     * @param taskId
     * @param selectionScopePre
     * @return
     */
    Boolean setCourseByMajor(List<Integer> idList, Double preCreditLimit, Integer preCourseLimit, Double creditLimit, Integer courseLimit, Integer flag, Integer selectionScope, Integer taskId, Integer selectionScopePre);

    /**
     * 根据学生获取选课教学班列表
     *
     * @param studentId
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<TeachingClassDto> getTeachingClassListByStudent(Integer studentId, Integer pageSize, Integer currentPage, Integer taskId);

    /**
     * 查看在线选课选课日志
     *
     * @param baseCollegeId
     * @param gradeId
     * @param classId
     * @param courseId
     * @param startDateTime
     * @param endDateTime
     * @param keyword
     * @param pageSize
     * @param currentPage
     * @param taskId
     * @return
     */
    ResultDto<CssLogsDto> getCssLogs(Long roundId, String baseCollegeId, String gradeId, String classId, Optional<Integer> courseId, String startDateTime, String endDateTime, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    Boolean addTempCourse(List<CssSelectCourse> list, Integer type, Integer taskId);

    Boolean deleteTempCourse(List<Long> IdList, Integer type, Integer taskId);

    List<RoundListDto> getRoundListSelf(Integer taskId);

    List<BaseCourse> getBaseCourse(String schoolId, Integer taskId);

    ResultDto<StudentInfoDto> getStudentInfoList(String baseCollegeId, String gradeId, String classId, String keyword, Integer pageSize, Integer currentPage, Integer taskId);

    ResultDto<StudentSelectInfoDto> getStudentSelectList(String baseCollegeId, String gradeId, String classId, String keyword, Integer pageSize, Integer currentPage, Integer taskId, Integer needToSelect, Integer flag, Integer roundId);

    AccessSelectedStudentDto accessSelectedStudents(Long studentId, Integer pageSize, Integer currentPage, Integer taskId, Integer flag, Integer roundId);

    ResultDto<TeachingClass> getStudentRetakeClass(String baseCollegeId, Long courseId, String keyword, Integer pageSize, Integer currentPage, Integer taskId, Integer flag, Integer roundId);

    ResultDto<TeachingClassDto> getTeachingClassListSelf(Integer pageSize, Integer currentPage, Integer taskId, Integer colloegId);

    Boolean clearTeachingClassSelf(List<Long> teachingClassIds, Integer taskId);

    TeachingClassSelfDto setTeachingClassSelf(Integer collegeId, String collegeName, Integer total, Long roundId, String uuidForOption, Integer type, Integer sum, Integer capacity, Integer taskId);

    CourseSelectionDto getCourseSelectionSelf(Integer roundId, Integer taskId);

    String cancelClasses(Long teachingClassId, String authorization, String userId, String userName, Integer taskId);

    List<Student> getStudentListConfirmSelectionResults(Integer taskId, Long courseId, Integer flag);

    String addStudentRetakeTeachingClass(List<AddTeachingClassDto> list, Integer taskId, String baseCollegeId, String collegeName, String gradeId, String gradeName, Integer campusId, String campusName);

    void importSelfCourseTeachingClass(HttpServletResponse response, Integer taskId, Integer flag, String uuid, MultipartFile file);

    Boolean selectConflictCheck(Integer taskId, Long studentId, Long teachingClassId, String ids);

    List<ScheduleRedisDto> getStudentSchedule(Integer taskId, Long studentId);
}
